#include <iostream>
#include <queue>
using namespace std;
int m, n;
const int N = 1e4 + 10;
bool st[N];
int cnt;
int main()
{
    cin >> m >> n;
    queue<int> q;
    while(n--)
    {
        int x;
        cin >> x;
        if(!st[x])
        {
            if(q.size() < m)
            {
                q.push(x);
                st[x] = true;
                cnt++;
            }
            else
            {
                st[q.front()] = false;
                q.pop();
                q.push(x);
                st[x] = true;
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}